# -*- coding: utf-8 -*

def guessEncoding(stri):
    for c in ('gbk', 'utf-8', 'big5', 'jp', 'euc_kr','utf16','utf32'): 
        try:
            stri.decode(c)
            return c
        except: 
            pass 
    return None

def zh2utf8(stri): 
    """Auto converter encodings to utf8
    It will test utf8,gbk,big5,jp,kr to converter""" 
    c = guessEncoding(stri) 
    if c:
        try:
            return stri.decode(c).encode('utf8') 
        except: 
            pass 
    return None 

def gbk2utf8(stri):
    return stri.decode("gbk").encode("utf8").replace('gbk', 'utf-8');

if __name__ == '__main__':
    input = open('dict.py')
    content = input.read()
    print guessEncoding(content)

